#include <termios.h>
#include <stdio.h>
#include <stdlib.h>

#define PASSWORD_LEN	8

int main()
{
	struct termios initialrsettings, newrsettings;
	char password[PASSWORD_LEN + 1];

	tcgetattr(fileno(stdin), &initialrsettings);

	newrsettings = initialrsettings;
	newrsettings.c_lflag &= ~ECHO;
	
	printf("Enter password: ");

	if(tcsetattr(fileno(stdin), TCSAFLUSH, &newrsettings) != 0) {
		fprintf(stderr, "could not set attributes\n");
	} else {
		fgets(password, PASSWORD_LEN, stdin);
		tcsetattr(fileno(stdin), TCSANOW, &initialrsettings);
		fprintf(stdout, "\nyou entered %s\n", password);
	}

	exit(0);
}
